<?php
@session_start();

$_anu	= new anuncios(); #CLASSES

#SETA CLIENTE
$_anu->cliente	= $_SESSION['idcliente'];

###############################################
#LISTA TODOS OS ANUNCIOS ATIVOS################
$where			= "WHERE cliente = '".$_SESSION['idcliente']."' ";
$order			= " ORDER BY id ";
$limit			= "";
$dadostotal		= $_anu->lista($where,$order,$limit);
###############################################
###############################################

//print_r($_SESSION);

?>
<style type="text/css">
#TableDestalhes{ border:solid 1px #CCCCCC; border-collapse:collapse}
#TableDestalhes h3{ font-weight:normal; text-transform:none; margin:0px}
#TableDestalhes tr td {border:1px solid #CCCCCC; padding:4px}
#TableDestalhes tr td a { text-decoration:none; color:#3B59AA; text-transform:capitalize; font-size:11px}
#TableDestalhes tr td a:hover { text-decoration:undeline; color:#3B59AA; font-size:11px}
</style>
<style type="text/css">
<!--
.span-verde {color:#0C0
}
-->
</style>



<div id="barra-painel">

<h1>Meus an&uacute;ncios</h1>	

<table width="100%" id="TableDestalhes">
   
  <tr style="color:#666; background-color:#F2F2F2">
     <td width="77" align="left" valign="top"><h3>Status</h3></td>
    <td width="75" align="left" valign="top"><h3>Cod</h3></td>
    <td width="547" align="left" valign="top"><h3>Item</h3></td>
    <td width="91" valign="top"><h3>A&ccedil;&otilde;es</h3></td>
  </tr>
  
  <?php if(count($dadostotal)==0){	?>
  
  <tr>
    <td colspan="4" align="left" valign="top">N&atilde;o existem an&uacute;ncios.</td>
  </tr>
  
  <? }else{
	
	foreach($dadostotal as $dados){ 
	$x%2 == 0?$corfundo = "#FFFFFF":$corfundo = "#F2F2F2";
	
	if($dados["ativo"]==0){
	$status	= "<span style=\"color:#700\">Finalizado</span>";
	}else{
	$status	= "<span style=\"color:#070\">Ativo</span>";
	}
	
	?>
  
  <tr bgcolor="<?=$corfundo?>">
  <td width="77" align="left" valign="top" style="text-transform:lowercase"><? echo $status; ?></td>
   <td><?php echo $dados['id']; ?></td>
    
    <td align="left" valign="top"><span style="text-transform:capitalize"><?=htmlentities($dados['titulo'])?></span></td>
    
    <td valign="top">
    
    <a href="painel.php?acao=edita-anuncio&anuncio=<?=$dados['id']?>">editar</a> | <?php if($dados["ativo"]==0){ ?>        <a href="modulos/painel/anuncios/acao.php?acao=ativar&id=<?=$dados['id']?>" onClick="javascript: if(confirm('Deseja reativar este an&uacute;ncio?')){ return true }else{return false; }">ativar</a>
<? }else{ ?>
<a href="modulos/painel/anuncios/acao.php?acao=desativar&id=<?=$dados['id']?>" onClick="javascript: if(confirm('Deseja realmente finalizar este an&uacute;ncio?')){ return true }else{return false; }">finalizar</a>
<? } ?>
    
    </td>
  </tr>
  
  <? $x++; } } ?>
  
  
</table>

</div>